home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / save < prev    next >
Text File  |  2006-10-19  |  5KB  |  189 lines

  1. ************************************************************
  2. *                                                          *
  3. *  I/O Op Code 6 - SAVE                                    *
  4. *                                                          *
  5. *  This routine will save a memory image file from VDP     *
  6. *  RAM.  It has been completely rewritten to use MKFDR     *
  7. *  to create the file header and use I/O routines that     *
  8. *  will write 512 byte blocks directly from VDP RAM.       *
  9. *                                                          *
  10. *  May 9, 1996 - fixed a bug that caused files greater     *
  11. *                than 1023 bytes in length to repeat the   *
  12. *                first two sectors over and over.          *
  13. *                                                          *
  14. ************************************************************
  15.  
  16. SAVE0  ANDI R12,>FF00
  17.        AI   R12,24
  18.  
  19.        LDCR @ZERO,4
  20.        MOV  @PABBUF+6,R1     Get # of bytes to write
  21.        LDCR @B02,4           Select RAM bank 4
  22.  
  23. * Set up the parameters for MKFDR
  24.  
  25.        CLR  @MKFL3           Level 3 records = 0
  26.        MOVB @ZERO,@MKFRL     Record Length = 0
  27.        MOVB @ZERO,@MKFRPS    Records/sector = 0
  28.        MOVB @B01,@MKFLAG     File Flags (Program file)
  29.  
  30.        SWPB R1
  31.        MOVB R1,@MKFEOF       End of file Offset
  32.        SWPB R1
  33.        AI   R1,255
  34.        SRL  R1,8
  35.        MOV  R1,@MKFSZ        # of sectors needed
  36.  
  37.        BL   @MKFDR           Make the FDR
  38.  
  39.        SLA  R1,1
  40.        MOV  @SAVJTB(R1),R1
  41.        B    *R1
  42.  
  43. SAVJTB DATA SAVE10
  44.        DATA SAVE1        Error code 1
  45.        DATA SAVE2        Error code 2
  46.        DATA SAVE3        Error code 3
  47.        DATA SAVE4        Error code 4
  48.        DATA SAVE5        Error code 5
  49.        DATA SAVE6        Error code 6
  50.        DATA SAVE7        Error code 7
  51.  
  52. SAVE1  BL   @DSRERR
  53.        DATA >0100
  54. SAVE2  BL   @DSRERR
  55.        DATA >0200
  56. SAVE3  BL   @DSRERR
  57.        DATA >0300
  58. SAVE4  BL   @DSRERR          to do this, don't you think?
  59.        DATA >0400
  60. SAVE5  BL   @DSRERR
  61.        DATA >0500
  62. SAVE6  BL   @DSRERR
  63.        DATA >0600
  64. SAVE7  BL   @DSRERR
  65.        DATA >0700
  66.  
  67. ************************************************************
  68.  
  69. SAVE10
  70.  
  71. * The FDR is on disk with a copy of it in the DFDR buffer.
  72. * All AUs for the file have been allocated.  Now start
  73. * writing the data to disk.
  74.  
  75.        LDCR @ZERO,4          Select RAM bank 0
  76.        MOV  @PABBUF+6,R1     R1 = # of bytes left to write
  77.        JEQ  SAVERT           Empty file, nothing left to do
  78.        MOV  @PABBUF+2,R11    R11 is our buffer pointer
  79.        LI   R10,DFDR+40
  80.        CLR  R5               Sector within AU
  81.  
  82. * Let's test to see if we can write out 512 bytes.  Otherwise,
  83. * we will have to read in a 512 byte block and overwrite 256
  84. * bytes of it.
  85. *
  86. * The check goes something like this -
  87. *   1.  Our sector buffer pointer must be at the beginning
  88. *       of the sector buffer
  89. *   2.  We must have at least 2 sectors left in this AU.
  90. *
  91.  
  92.        MOV  R6,R3
  93.        SRL  R3,8
  94.        SLA  R3,1
  95.        LDCR @B04,4
  96.        MOV  @SAUTBL(R3),R3
  97.        LDCR @B02,4           Select RAM bank 2
  98.  
  99. SAVE11 MOV  *R10+,R2         Get AU
  100. SAVE12
  101.        LI   R4,SECBUF
  102.        MOV  R2,R7
  103.        MPY  R3,R7
  104.        A    R5,R8
  105.        JNC  SAVE13
  106.        INC  R7
  107. SAVE13 SRL  R8,1
  108.        JNC  SAVE14
  109.        AI   R4,>100
  110. SAVE14 SRL  R7,1
  111.        JNC  SAVE15
  112.        ORI  R8,>8000
  113. SAVE15
  114.        LDCR @ZERO,4
  115.        CI   R4,SECBUF
  116.        JNE  SAVE16
  117.        MOV  R3,R0
  118.        DEC  R0
  119.        C    R0,R5
  120.        JEQ  SAVE16
  121.        CI   R1,512
  122.        JL   SAVE16
  123.        JMP  SAVE30
  124.  
  125. SAVE16 LI   R0,256
  126.        INC  R5
  127.        BLWP @BANKIT
  128.        DATA SCSIRD
  129.        JNE  SAVERR
  130.  
  131.        SWPB R11          Set VDP read address
  132.        MOVB R11,@VDPWA
  133.        SWPB R11
  134.        MOVB R11,@VDPWA
  135.        NOP
  136.  
  137. SAVE17 MOVB @VDPRD,*R4+
  138.        DEC  R1
  139.        JEQ  SAVE18
  140.        DEC  R0
  141.        JNE  SAVE17
  142. SAVE18 BLWP @BANKIT
  143.        DATA SCSIWT
  144.        JNE  SAVERR
  145.  
  146.        CI   R1,0             See if we're done
  147.        JEQ  SAVERT
  148.        AI   R11,256
  149. SAVE19
  150.        C    R5,R3
  151.        JL   SAVE12
  152.  
  153.        S    R3,R5
  154.        LDCR @B02,4
  155.        C    R2,*R10
  156.        JEQ  SAVE20
  157.        INC  R2
  158.        JMP  SAVE12
  159.  
  160. SAVE20 INCT R10
  161.        JMP  SAVE11
  162.  
  163. **
  164. *
  165. * SAVE30 - use sector I/O to write 512 bytes
  166. *
  167. **
  168. SAVE30 CLR  R0
  169.        MOVB R6,R0            SCSI ID
  170.        ORI  R0,>4000         VDP memory,absolute sector size
  171.        MOV  R0,@>834C
  172.        MOV  R11,@>834E
  173.        MOV  R8,@>8350        32 bit sector number
  174.        MOV  R7,@>8352
  175.  
  176.        LDCR @ZERO,4
  177.        BLWP @BANKIT
  178.        DATA SCSI20
  179.  
  180.        AI   R1,-512
  181.        JEQ  SAVERT
  182.        INCT R5
  183.        AI   R11,512
  184.        JMP  SAVE19
  185. SAVERT B    @DSRRT
  186.  
  187. SAVERR BL   @DSRERR
  188.        DATA >0600            Device error
  189.